using Sidvall.Data;
using System.Collections.Generic;

namespace Sidvall.Business
{
    public sealed class ValidationContext
    {
        #region Public Members

        public TaskContext TaskContext { get; }
        public ValidationSettings Settings { get; }
        #region AllBusinessRules

        private System.Lazy<BusinessRuleCollection> _AllBusinessRules = new System.Lazy<BusinessRuleCollection>();
        public BusinessRuleCollection AllBusinessRules
        {
            get
            {
                return _AllBusinessRules.Value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public ValidationContext() : this(null, null)
        {
        }
        public ValidationContext(ValidationSettings settings) : this(settings, null)
        {
        }
        public ValidationContext(ValidationSettings settings, IEnumerable<BusinessRule> allBusinessRules)
        {
            if (settings != null)
                this.Settings = settings;
            else
                this.Settings = new ValidationSettings();
            this.TaskContext = new TaskContext();
            this.AllBusinessRules.AddRange(true, allBusinessRules);
        }

        #endregion
    }
}
